#ifndef PLUGINMANAGER_H
#define PLUGINMANAGER_H
#include <QObject>
#include <QMenu>
#include <QPluginLoader>
#include <QDir>
#include <QDockWidget>
#include <QMainWindow>
#include "qfitsplugin.h"

class PluginManager : public QObject {
	Q_OBJECT
	/// All available plugins
	QList<QObject*> pluginList;
	/// Al used plugins.
	QList<QObject*> plugins;
	QDir pluginsDir;
	QStringList pluginFileNames;
	void addToMenu(QMenu *menu, QObject *plugin);
public:
	PluginManager(QObject *parent = 0);
	/**
	 * Load all the plugins in the menu and set pluginFileNames and pluginDir for future use.
	 * @param dirPath Path of the directory with dynamic plugins.
	 */
	void loadPlugins(QString dirPath);
	/**
	 * Dock the loaded plugins, put them in the menu and initialize them.
	 * @param menu The menu to put the plugins in.
	 */
	void populateMenu(QMenu *menu);
	QObject *getSender(){ return sender(); } // not conserved in signal-signal connections
	/**
	  *
	  * @return multiline string containing a restorable state of all the plugins
	  *         consisting of type, position, size and plugin state
	  */
	QString state();
public slots:
//	void setGray(double midValue, double grayScale);
//	void setColormap(QVector<QColor>);
signals:
	void grayChanged(double midValue, double grayScale);
	void colormapChanged(QVector<QColor> map);
};
#endif // PLUGINMANAGER_H
